package com.hudsonmq.spring.impl.produce.impl;


import com.hudson.codec.domain.Message;
import com.hudson.common.domain.Duration;
import com.hudson.core.concurrent.CallBack;
import com.hudsonmq.spring.impl.produce.RemoteClient;
import com.hudsonmq.spring.impl.produce.helper.SendMessageHelper;
import com.hudsonmq.spring.utils.SnowflakeIdGeneratorUtil;

public class OnewayRemoteClient implements RemoteClient {


    @Override
    public Boolean send(Message message, CallBack callBack) {
        long messageId = SnowflakeIdGeneratorUtil.getMessageId();

        SendMessageHelper.sendMessage(messageId, message, callBack);
        return null;
    }

    @Override
    public Boolean relaySend(Message message, CallBack callBack, Duration duration) {
        long messageId = SnowflakeIdGeneratorUtil.getMessageId();

        SendMessageHelper.sendRelayMessage(messageId, message, duration);

        return true;
    }
}
